﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Elements {
  public class StaticTintedBlendAnimation:StaticScreenPiece, IUIElement<StaticTintedBlendAnimation> {
    public StaticTintedBlendAnimation ( UIDocument doc , string name ) : base( doc , name ) {
    }
    public StaticTintedBlendAnimation ( UIDocument doc ) : this( doc , "StaticTintedBlendAnimation" ) {
    }

    #region IUIElement<StaticTintedBlendAnimation> Members

    public void Validate ( StaticTintedBlendAnimation val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        StaticTintedBlendAnimation el = new StaticTintedBlendAnimation( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( StaticTintedBlendAnimation val ) {
      base.Copy( val );

      if( !string.IsNullOrEmpty( val.Texture1 ) )
        this.Texture1 = val.Texture1;
      if( !string.IsNullOrEmpty( val.Texture2 ) )
        this.Texture2 = val.Texture2;
      if( val.Tint1 != null )
        this.Tint1 = val.Tint1;
      if( val.Tint2 != null )
        this.Tint2 = val.Tint2;
      if( val.MaxLayerOneTextures != null )
        this.MaxLayerOneTextures = val.MaxLayerOneTextures;
      if( val.MaxLayerTwoTextures != null )
        this.MaxLayerTwoTextures = val.MaxLayerTwoTextures;
      if( val.LayerOneTextureIndex != null )
        this.LayerOneTextureIndex = val.LayerOneTextureIndex;
      if( val.LayerTwoTextureIndex != null )
        this.LayerTwoTextureIndex = val.LayerTwoTextureIndex;
    }

    #endregion

    public string Texture1 {
      get {
        return this.GetElement( "Texture1" ).InnerText;
      }
      set {
        this.Validate( "Texture1" , value );
      }
    }
    public string Texture2 {
      get {
        return this.GetElement( "Texture2" ).InnerText;
      }
      set {
        this.Validate( "Texture2" , value );
      }
    }
    public RGB Tint1 {
      get {
        return ( RGB ) this.GetElement( "Tint1" );
      }
      set {
        this.Tint1.Validate( value , "Tint1" );
      }
    }
    public RGB Tint2 {
      get {
        return ( RGB ) this.GetElement( "Tint2" );
      }
      set {
        this.Tint2.Validate( value , "Tint2" );
      }
    }
    public int? MaxLayerOneTextures {
      get {
        return int.Parse( this.GetElement( "MaxLayerOneTextures" ).InnerText );
      }
      set {
        this.Validate( "MaxLayerOneTextures" , value.ToString() );
      }
    }
    public int? MaxLayerTwoTextures {
      get {
        return int.Parse( this.GetElement( "MaxLayerTwoTextures" ).InnerText );
      }
      set {
        this.Validate( "MaxLayerTwoTextures" , value.ToString() );
      }
    }
    public int? LayerOneTextureIndex {
      get {
        return int.Parse( this.GetElement( "LayerOneTextureIndex" ).InnerText );
      }
      set {
        this.Validate( "LayerOneTextureIndex" , value.ToString() );
      }
    }
    public int? LayerTwoTextureIndex {
      get {
        return int.Parse( this.GetElement( "LayerTwoTextureIndex" ).InnerText );
      }
      set {
        this.Validate( "LayerTwoTextureIndex" , value.ToString() );
      }
    }

  }
}
